package com.sheliduan.itlearning.admin.controller;

import com.sheliduan.itlearning.admin.model.vos.category.AddCategoryReqVO;
import com.sheliduan.itlearning.admin.model.vos.category.DeleteCategoryReqVO;
import com.sheliduan.itlearning.admin.model.vos.category.FindCategoryPageListReqVO;
import com.sheliduan.itlearning.admin.model.vos.tag.UpdateTagReqVO;
import com.sheliduan.itlearning.admin.service.AdminCategoryService;
import com.sheliduan.itlearning.common.aspect.ApiOperationLog;
import com.sheliduan.itlearning.common.model.vos.IdReqVO;
import com.sheliduan.itlearning.common.utils.PageResponseData;
import com.sheliduan.itlearning.common.utils.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 断舍离
 * @date: 2025/2/18 10:09
 * @description: 后台管理员分类控制器
 **/
@RestController
@RequestMapping("/admin")
public class AdminCategoryController {

    @Autowired
    private AdminCategoryService adminCategoryService;

    @PostMapping("/category/pageList")
    @ApiOperationLog(description = "分类分页数据获取")
    public PageResponseData findCategoryPageList(@RequestBody@Validated FindCategoryPageListReqVO findCategoryPageListReqVo){
        return adminCategoryService.findCategoryPageList(findCategoryPageListReqVo);
    }

    @PostMapping("/category/add")
    @ApiOperationLog(description = "添加分类")
    public ResponseData addCategory(@RequestBody @Validated AddCategoryReqVO addCategoryReqVo){
        return adminCategoryService.addCategory(addCategoryReqVo);
    }

    @PostMapping("/category/delete")
    @ApiOperationLog(description = "删除分类")
    public ResponseData deleteCategory(@RequestBody @Validated DeleteCategoryReqVO deleteCategoryReqVo){
        return adminCategoryService.deleteCategory(deleteCategoryReqVo);
    }

    @PostMapping("/category/update")
    @ApiOperationLog(description = "修改分类")
    public ResponseData updateCategory(@RequestBody @Validated UpdateTagReqVO updateTagReqVO){
        return adminCategoryService.updateCategory(updateTagReqVO);
    }

    @PostMapping("/category/selectById")
    @ApiOperationLog(description = "根据id查找分类")
    public ResponseData selectById(@RequestBody @Validated IdReqVO idReqVO) {
        return adminCategoryService.selectById(idReqVO.getId());
    }

}
